package cn.iocoder.yudao.module.system.controller.app.expert;

import cn.iocoder.yudao.framework.common.enums.WrittenExamTypeEnum;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.system.controller.admin.expert.vo.ExpertRespVO;
import cn.iocoder.yudao.module.system.dal.dataobject.expert.ExpertDO;
import cn.iocoder.yudao.module.system.service.expert.SystemWrittenExamExpertRelService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

@Tag(name = "用户（有关笔试） - 专家")
@RestController
@RequestMapping("/system/expert")
@Validated
public class AppExpertController {

    @Resource
    private SystemWrittenExamExpertRelService systemWrittenExamExpertRelService;

    /**
     * 根据笔试类型获得专家列表 {@link WrittenExamTypeEnum}
     *
     * @param writtenExamType
     * @return
     */
    @GetMapping("/list-by-type")
    @Operation(summary = "根据笔试类型获得专家列表")
    public CommonResult<List<ExpertRespVO>> getExpertListByWrittenExamType(
            @RequestParam(name = "writtenExamType", required = false) Integer writtenExamType) {
        List<ExpertDO> list = systemWrittenExamExpertRelService.getExpertListByWrittenExamType(writtenExamType);
        return success(BeanUtils.toBean(list, ExpertRespVO.class));
    }

}